package ls.vuecp.gui.component;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Rectangle2D;

import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import com.lightdev.app.shtm.SHTMLEditorKit;

import tufts.vue.VueConstants;
import tufts.vue.VueUtil;
import tufts.vue.gui.GUI;

public class RichTextBox extends com.lightdev.app.shtm.SHTMLEditorPane
	implements VueConstants
	, FocusListener
	, KeyListener
	, DocumentListener
	, MouseListener
	, ActionListener
{
	RichTextBox(LWComponent lwc)
    {
        this(lwc, null);
    }
    RichTextBox(LWComponent lwc, String text)
    {
    	this.lwc = lwc;
       
    	if (text != null)
           setText(text);
       
    	SHTMLEditorKit kit = new SHTMLEditorKit(/* renderMode */);
		//kit.resetStyleSheet();
    	setEditorKit(kit);
    	
       setDragEnabled(false);
       setBorder(null);
       
       setMargin(null);
       setOpaque(false); // don't bother to paint background
       setVisible(true);
       
       addMouseListener(this);
       addKeyListener(this);
       addFocusListener(this);
       getDocument().addDocumentListener(this);
     
       if (VueUtil.isWindowsPlatform() && SelectionColor != null)
           setSelectionColor(SelectionColor);      
       if (VueUtil.isWindowsPlatform() && SelectionColor != null)
       	setSelectedTextColor(Color.black);
       
       mBounds.x = Float.NaN; // mark as uninitialized
       mBounds.y = Float.NaN; // mark as uninitialized
    }
	private LWComponent lwc;
	private final Rectangle2D.Float mBounds = new Rectangle2D.Float();
    private boolean wasOpaque; /** were we opaque before we started an edit? */
    private float mMaxCharWidth;
    private float mMaxWordWidth;
    private static final Color SelectionColor = GUI.getTextHighlightColor();//VueResources.getColor("mapViewer.textBox.selection.color");
    private boolean revert = false;
	
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void insertUpdate(DocumentEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removeUpdate(DocumentEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void changedUpdate(DocumentEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void focusGained(FocusEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void focusLost(FocusEvent e) {
		// TODO Auto-generated method stub
		
	}
}
